﻿using Assets.Scripts.DL.Consts;
using Assets.Scripts.DL.Mgrs;
using UnityEngine;


public class ReBoundCheck : MonoBehaviour {
	PlayerController _controller;

	private void Awake() {
		_controller = GetComponentInParent<PlayerController>();
	}

	private void OnTriggerEnter2D(Collider2D collision) {
		if (collision.CompareTag(Tags.EnemyRemoteAtk)) {
			var sec = _controller.ConfigData.ReboundTimeSlowSec;
			var scale = _controller.ConfigData.SlowTimeScale;
			_controller.SetTimeScale(sec, scale);
			collision.tag = Tags.PlayerRemoteAtk;
#warning ToDO 特效 停顿 抖动
			var rb = collision.GetComponent<Rigidbody2D>();
#if UNITY_EDITOR
			if (rb != null) {
				Debug.Log("NoRbInIt");
				return;
			}
#endif
			//rb.velocity *= -1;
			var audiosource = GetComponentInParent<PlayerController>().Effect;
			AudioManager.Play(audiosource, AudioStr.Rebound);
			ScreenEffectMgr.Instance.WaveEffect(transform.position);
			//Debug.Log("REbound");
		}
	}
}

